@extends("layouts.common")
@section("content")
    <div class="row">
        <div class="col-lg-12">
            @if (isset($errors) && count($errors) > 0)
                <div class="alert alert-danger alert-dismissible">
                    <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                    <h4><i class="icon fa fa-ban"></i> 错误</h4>
                    <ul>
                        @foreach ($errors->all() as $error)
                            <li>{{ $error }}</li>
                        @endforeach
                    </ul>
                </div>
            @endif
                @if (Session::has('messages'))
                    <div class="alert alert-success alert-dismissible">
                        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                        <h4><i class="icon fa fa-check"></i> 成功!</h4>
                        <ul>
                            @foreach (Session::get('messages') as $error)
                                <li>{{ $error }}</li>
                            @endforeach
                        </ul>
                    </div>
                @endif
        </div>
    </div>

    <div class="row error" style="display: none">
        <div class="col-lg-12">
                <div class="alert alert-danger alert-dismissible">
                    <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                    <h4><i class="icon fa fa-ban"></i> 错误</h4>
                    <ul>
                            <li></li>
                    </ul>
                </div>
        </div>
    </div>


    <div class="row">
        <div class="col-lg-12">
            <h3 class="page-header"><i class="fa fa-table"></i>系统设置</h3>
            <ol class="breadcrumb">
                <li><i class="fa fa-home"></i><a href="/welcome">Home</a></li>
                <li><i class="fa fa-indent"></i>系统设置</li>
            </ol>
        </div>
    </div>

    <div class="row">

        <div class="col-md-12">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h2><i class="fa fa-indent red"></i><strong>系统设置</strong></h2>
                    <div class="panel-actions">
                        <a  data-toggle="modal" data-target="#active" style="cursor:pointer;"><i class="fa  fa-plus"></i>添加配置&nbsp;&nbsp;</a>
                    </div>
                </div>
                <form action="" method="post" enctype="multipart/form-data" class="form-horizontal ">
                <div class="panel-body">

                    @foreach($basic as $value)
                        <div class="form-group">
                            <label class="col-md-2 control-label" for="text-input">提成{{ $value->desc }}</label>
                            <div class="col-md-8">
                                <input type="text" id="text-input" name="{{ $value->id }}" class="form-control" value="{{$value->value}}">
                                <span class="help-block">{{$value->notice}}</span>
                            </div>
                            <div class="col-md-1 control-label delete"  data-toggle="modal" data-target="#delete"  data-id="{{ $value->id }}" style="cursor:pointer">
                                <i class="fa fa-minus-square red"></i>
                            </div>
                        </div>
                    @endforeach


                        {!! csrf_field() !!}

                </div>
                <div class="panel-footer">
                    <div class="col-md-2"></div>
                    <div> <button type="submit" class="btn btn-sm btn-success"><i class="fa fa-dot-circle-o"></i> Submit</button></div>
                </div>
                </form>
            </div>
        </div>
    </div>
    <div class="modal fade" id="active" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <form action="/basic/set" method="post" enctype="multipart/form-data" class="form-horizontal ">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="myModalLabel">添加设置</h4>
                </div>
                <div class="modal-body">

                        <div class="panel-body">
                            <div class="form-group">
                                <label class="col-md-2 control-label" for="text-input">提成</label>
                                <div class="col-md-9">
                                    <input type="number" id="text-input" name="percent" class="form-control" value="{{old('percent')}}" placeholder="提成" required>
                                    <span class="help-block">输入整数即可，不需加%</span>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-md-2 control-label" for="text-input">业绩值</label>
                                <div class="col-md-9">
                                    <input type="text" id="text-input" name="number" class="form-control" value="{{old('number')}}" placeholder="业绩值" required>
                                </div>
                            </div>


                            {!! csrf_field() !!}

                        </div>

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <button  type="submit" class="btn btn-info active btn-sm model_delete" data-val="" role="button">确定</button>
                </div>
                </form>
            </div>
        </div>
    </div>
    <div class="modal fade" id="delete" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="myModalLabel">警告</h4>
                </div>
                <div class="modal-body">
                    你确定要删除这个配置吗？
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <a  class="btn btn-danger active btn-sm model_delete" data-val="" role="button">确定</a>
                </div>
            </div>
        </div>
    </div>
    <script>
        $(function () {
            $(".delete").click(function(){
                $("#delete").find('.modal-footer .btn-danger').attr('href', "/basic/delete/" + $(this).attr("data-id"));
            });
        });

    </script>
    <style>
        td,th{
            text-align: center;
        }
    </style>
@endsection